<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.11.3.min.js"></script>
<title>file upload</title>
<script type="text/javascript">
	$(function() {
		console.log("start");
		$("#btnupfile").click(function(){
			console.log("file click");
			//console.log(upfile1.files[0]);
		  var  mydata = document.getElementById("mydata").value;  
		//  var  formData = new FormData(document.getElementById("upform"));
		var  formData = new FormData();
		    formData.append("myfile1",upfile1.files[0]); 
		    formData.append("myfile1",upfile2.files[0]);
		    formData.append("myfile1",upfile3.files[0]);
		   // formData.append("myfile2", myfile2.files[0]);  
		    formData.append("mydata", mydata);  
		    formData.append("dfdfdf", "bbbb"); 
		    formData.append("dfdfdf", ""); 
		    formData.append("dfdfdf", "aaaa"); 
		    $.ajax({    
		      //  contentType:"multipart/form-data",  
		        url:"upload",    
		        type:"POST",  
		        data:formData,  
		        dataType:"text",  
		        processData: false,  // 告诉jQuery不要去处理发送的数据  
		        contentType: false,   // 告诉jQuery不要去设置Content-Type请求头  
		        success: function(data){ 
		        	console.log("success");
		        	console.log(data);
		            //document.getElementById("tip").innerHTML = data;  
		        },error:function(data){
		        	console.log("error");
		        	console.log(data);
		        } 
		    });  
		});

	});
</script>

</head>
<body>
<h2>文件上传实例--<span>${upkey}</span></h2> 

	<div>
		<h1>异步文件上传</h1>
		<div>
			<input type="file" name="upfile" id="upfile1" /><br />
			<input type="file" name="upfile" id="upfile2" /><br />
			<input type="file" name="upfile" id="upfile3" /><br />
			  说几句吧：<input type="text" name="mydata" id="mydata"/><br/>  
			<input type="button" name="btnupfile" id="btnupfile" value="async upload"/> 
		</div>
	</div>








<!-- <form action="upload" method="post" enctype="multipart/form-data"> 
  选择文件:<input type="file" name="file"> 
  <input type="submit" value="提交">  
</form>  -->
</body>
</html>